package com.jiajia.study;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;

/**
 * @Title: TopicApplication
 * @Author zjj
 * @Package com.jiajia.study
 * @Date 2024/3/8 12:30
 * @description:
 */
@SpringBootApplication
public class TopicApplication implements ApplicationRunner {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public static void main(String[] args) {
        SpringApplication.run(TopicApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Thread.sleep(3000);
        rabbitTemplate.convertAndSend("topic.exchange.a","a.orange.a",new Message("hello topic test1".getBytes(StandardCharsets.UTF_8)));
        rabbitTemplate.convertAndSend("topic.exchange.a","lazy",new Message("hello topic test2".getBytes(StandardCharsets.UTF_8)));
    }
}
